"""
@title(TenX腾晓2024年12月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
@license(CC BY-SA 4.0 License)
"""
import os
from copy import deepcopy


class TenXClass:
    def __init__(self):
        # 获取当前文件名并截取文件名的学号-姓名
        file_name = os.path.basename(__file__).split('.')[0].split("-")
        self.id = file_name[0]  # 学号
        self.name = file_name[1]  # 姓名

    @staticmethod
    def question1(*args) -> list[str]:
        binary_tree = deepcopy(args[0])  # 传入的地牢结构（二叉树），详细请看BinaryTree.py
        list1=[]
        list2=[]
        def find(node,list1,list2,level=0):
            if node is not None:
                list1.append(str(node.value))
                find(node.left,list1,list2,level+1)
                find(node.right,list1,list2,level+1)
                if node.left is None and node.right is None:
                    if node.value=="0":
                        print(list1)
                        text=""
                        for a in list1[1:]:
                            text=text+str(a)

                        list2.append(text)
                        list1.pop()
                    else:
                        list1.pop()
                else:list1.pop()
            return list2
        list3=find(binary_tree.root,list1,list2)
        #print(list3)
        return list3

    @staticmethod
    def question2(*args) -> str:
        matrix = deepcopy(args[0])  # 传入的河流结构（矩阵）
        def find(list1, level, len, list2):
            b = 0
            for a in list1[level]:
                if a >= b:
                    b = a
            level += 1
            list2.append(b)
            if level < len:
                find(list1, level, len, list2)
            return list2
        list2 = []
        a = len(matrix)
        level = 0
        list2 = find(matrix, level, a, list2)
        text = ""
        for a in list2:
            text = text + str(a)
        print(text)
        return text

    @staticmethod
    def question3(*args) -> int:
        res=6*(7**999)-5*(6**999)
        res=res%mod
        return res

    @staticmethod
    def question4(*args) -> int:
        n = deepcopy(args[0])  # 用于搭建金字塔的球个数
        cnt = 0
        Sum = 0

        def find(n, cnt, Sum):
            while True:
                cnt += 1
                Sum += cnt * (cnt + 1) // 2
                if Sum == n:
                    print(cnt)
                    return cnt
                elif Sum > n:
                    print(cnt - 1)
                    return cnt - 1

        cnt = find(n, cnt, Sum)
        return  cnt

    @staticmethod
    def question5(*args) -> str:
        balls = deepcopy(args[0])  # 五行空间球的初始值

        def Renew(list1, cnt, a, b):
            print(f"第{cnt}个球更新：{list1[a]}+{list1[b]}={list1[a] + list1[b]}")
            print(f"更新之前的列表：{list1}")
            c = list1[a] + list1[b]
            list1[cnt - 1] = c
            return list1

        amount = 0
        cnt=0
        while True:
            cnt += 1
            if cnt == 1:
                balls = Renew(balls, cnt, 3, 4)
            elif cnt == 2:
                balls = Renew(balls, cnt, 4, 0)
            elif cnt == 3:
                balls = Renew(balls, cnt, 0, 1)
            elif cnt == 4:
                balls = Renew(balls, cnt, 1, 2)
            elif cnt == 5:
                balls = Renew(balls, cnt, 2, 3)
            if cnt == 5:
                cnt = 0
            if balls[cnt - 1] >= 10000:
                amount += 1
                if amount == 5:
                    break
        list2=[]
        for a in balls:
            list2.append(str(a))
        return  list2